GtkApplication: simplify session quit handling
authorRyan Lortie <desrt@desrt.ca>
Mon, 20 Feb 2012 21:22:10 +0000 (22:22 +0100)
committerRyan Lortie <desrt@desrt.ca>
Tue, 21 Feb 2012 00:23:01 +0000 (01:23 +0100)
Instead of firing a 'quit' signal and expecting the application to do
something that will cause it to quit, just call the new
g_application_quit() API for ourselves.

https://bugzilla.gnome.org/show_bug.cgi?id=670485

gtk/gtkapplication.c
gtk/gtkapplication.h

index 241122601d812ddb0087fcb22576c41a31dafd16..7ca5a8ef77673b3ae0dfee3268c8304581dbb3ec 100644 (file)
 enum {
   WINDOW_ADDED,
   WINDOW_REMOVED,
-  QUIT,
   LAST_SIGNAL
 };
 
@@ -680,13 +679,6 @@ gtk_application_set_property (GObject      *object,
     }
 }
 
-static void
-gtk_application_quit (GtkApplication *app)
-{
-  /* we are asked to quit, so don't linger */
-  g_application_set_inactivity_timeout (G_APPLICATION (app), 0);
-}
-
 static void
 gtk_application_finalize (GObject *object)
 {
@@ -717,7 +709,6 @@ gtk_application_class_init (GtkApplicationClass *class)
 
   class->window_added = gtk_application_window_added;
   class->window_removed = gtk_application_window_removed;
-  class->quit = gtk_application_quit;
 
   g_type_class_add_private (class, sizeof (GtkApplicationPrivate));
 
@@ -756,32 +747,6 @@ gtk_application_class_init (GtkApplicationClass *class)
                   g_cclosure_marshal_VOID__OBJECT,
                   G_TYPE_NONE, 1, GTK_TYPE_WINDOW);
 
-  /**
-   * GtkApplication::quit:
-   * @application: the #GtkApplication
-   *
-   * Emitted when the session manager wants the application to quit
-   * (generally because the user is logging out). The application
-   * should exit as soon as possible after receiving this signal; if
-   * it does not, the session manager may choose to forcibly kill it.
-   *
-   * Normally, an application would only be sent a ::quit if there
-   * are no inhibitors (see gtk_application_inhibit()).
-   * However, this is not guaranteed; in some situations the
-   * session manager may decide to end the session without giving
-   * applications a chance to object.
-   *
-   * To receive this signal, you need to set the
-   * #GtkApplication:register-session property
-   * when creating the application object.
-   *
-   * Since: 3.4
-   */
-  gtk_application_signals[QUIT] =
-    g_signal_new ("quit", GTK_TYPE_APPLICATION, G_SIGNAL_RUN_FIRST,
-                  G_STRUCT_OFFSET (GtkApplicationClass, quit),
-                  NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
   /**
    * GtkApplication:register-session:
    *
@@ -1229,13 +1194,13 @@ client_proxy_signal (GDBusProxy     *proxy,
       g_debug ("Received EndSession");
       gtk_application_quit_response (app, TRUE, NULL);
       unregister_client (app);
-      g_signal_emit (app, gtk_application_signals[QUIT], 0);
+      g_application_quit (G_APPLICATION (app));
     }
   else if (strcmp (signal_name, "Stop") == 0)
     {
       g_debug ("Received Stop");
       unregister_client (app);
-      g_signal_emit (app, gtk_application_signals[QUIT], 0);
+      g_application_quit (G_APPLICATION (app));
     }
 }
 
@@ -1508,7 +1473,7 @@ idle_will_quit (gpointer data)
   GtkApplication *app = data;
 
   if (app->priv->quit_inhibit == 0)
-    g_signal_emit (app, gtk_application_signals[QUIT], 0);
+    g_application_quit (G_APPLICATION (app));
   else
     {
       GtkApplicationQuartzInhibitor *inhibitor;
index 092d90c130a96660f7c521cc283e967cebb8dbfe..cae9e64d7cddfc962364cd283a201fc1d12234a4 100644 (file)
@@ -59,10 +59,8 @@ struct _GtkApplicationClass
   void (*window_removed) (GtkApplication *application,
                           GtkWindow      *window);
 
-  void (*quit)           (GtkApplication *application);
-
   /*< private >*/
-  gpointer padding[11];
+  gpointer padding[12];
 };
 
 GType            gtk_application_get_type      (void) G_GNUC_CONST;